package com.cn.steam.iam.controller.pub;

import com.cn.steam.foundation.common.model.exception.BadRequestException;
import com.cn.steam.iam.model.vo.OnBehalfSslRes;
import com.cn.steam.iam.service.IamPrivilegeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.cn.steam.foundation.common.model.CommonConstant.COMMON_PUBLIC_AUTH_APIS_V1_PREFIX;

/**
 * @author huangzz
 */
@RestController
@RequestMapping(COMMON_PUBLIC_AUTH_APIS_V1_PREFIX)
public class IamAuthController {
	@Autowired
	private IamPrivilegeService iamPrivilegeService;

	@GetMapping("/on-behalf-ssl/{sslCode}")
	public OnBehalfSslRes OnBehalfSsl(@PathVariable String sslCode) {
		if (StringUtils.isBlank(sslCode)) {
			throw new BadRequestException("ssl code can not be empty.");
		}
		return iamPrivilegeService.expenseSslCode(sslCode);
	}



}
